package com.edu.exam.entity.curriculum.questionbank;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Comment;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 判断题质量评估实体类
 * 对应数据库表：true_false_question_quality
 *
 * 根据B-02-03-06判断题管理子模块设计文档实现
 * 管理判断题的质量评估信息，包括多维度质量评分和改进建议。
 * 支持自动化质量评估和人工审核。
 *
 * @author System
 * @version 1.0.0
 */
@Entity
@Table(name = "true_false_question_quality")
@Comment("判断题质量评估表")
@EntityListeners(AuditingEntityListener.class)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TrueFalseQuestionQuality {

    /**
     * 主键ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    /**
     * 质量评估唯一标识符
     */
    @NotBlank(message = "质量评估ID不能为空")
    @Size(max = 50, message = "质量评估ID长度不能超过50个字符")
    @Column(name = "quality_id", nullable = false, length = 50, unique = true)
    private String qualityId;

    /**
     * 关联的判断题ID
     */
    @NotBlank(message = "题目ID不能为空")
    @Column(name = "question_id", nullable = false)
    private String questionId;

    /**
     * 内容质量评分（0-100分）
     */
    @Column(name = "content_quality", precision = 5, scale = 2)
    private BigDecimal contentQuality;

    /**
     * 逻辑质量评分（0-100分）
     */
    @Column(name = "logical_quality", precision = 5, scale = 2)
    private BigDecimal logicalQuality;

    /**
     * 教学质量评分（0-100分）
     */
    @Column(name = "teaching_quality", precision = 5, scale = 2)
    private BigDecimal teachingQuality;

    /**
     * 技术质量评分（0-100分）
     */
    @Column(name = "technical_quality", precision = 5, scale = 2)
    private BigDecimal technicalQuality;

    /**
     * 综合质量评分（0-100分）
     */
    @Column(name = "overall_quality", precision = 5, scale = 2)
    private BigDecimal overallQuality;

    /**
     * 质量等级（EXCELLENT-优秀，GOOD-良好，FAIR-一般，POOR-较差）
     */
    @Size(max = 20, message = "质量等级长度不能超过20个字符")
    @Column(name = "quality_level", length = 20)
    private String qualityLevel;

    /**
     * 评估类型（AUTOMATIC-自动评估，MANUAL-人工评估，HYBRID-混合评估）
     */
    @NotBlank(message = "评估类型不能为空")
    @Size(max = 20, message = "评估类型长度不能超过20个字符")
    @Column(name = "evaluation_type", nullable = false, length = 20)
    private String evaluationType;

    /**
     * 评估标准（JSON格式，包含评估细则）
     */
    @Column(name = "evaluation_criteria", columnDefinition = "TEXT")
    private String evaluationCriteria;

    /**
     * 评估详情（JSON格式，包含各项评分详情）
     */
    @Column(name = "evaluation_details", columnDefinition = "TEXT")
    private String evaluationDetails;

    /**
     * 改进建议（JSON格式，包含具体的改进建议）
     */
    @Column(name = "improvement_suggestions", columnDefinition = "TEXT")
    private String improvementSuggestions;

    /**
     * 问题识别（JSON格式，识别的问题列表）
     */
    @Column(name = "identified_issues", columnDefinition = "TEXT")
    private String identifiedIssues;

    /**
     * 评估置信度（0-1之间）
     */
    @Column(name = "confidence_level", precision = 3, scale = 2)
    private BigDecimal confidenceLevel;

    /**
     * 评估者ID
     */
    @Size(max = 50, message = "评估者ID长度不能超过50个字符")
    @Column(name = "evaluator_id", length = 50)
    private String evaluatorId;

    /**
     * 评估者姓名
     */
    @Size(max = 50, message = "评估者姓名长度不能超过50个字符")
    @Column(name = "evaluator_name", length = 50)
    private String evaluatorName;

    /**
     * 评估者角色（EXPERT-专家，TEACHER-教师，ADMIN-管理员，SYSTEM-系统）
     */
    @Size(max = 30, message = "评估者角色长度不能超过30个字符")
    @Column(name = "evaluator_role", length = 30)
    private String evaluatorRole;

    /**
     * 评估时间
     */
    @NotNull(message = "评估时间不能为空")
    @Column(name = "evaluation_time", nullable = false)
    private LocalDateTime evaluationTime;

    /**
     * 评估耗时（分钟）
     */
    @Column(name = "evaluation_duration_minutes")
    private Integer evaluationDurationMinutes;

    /**
     * 评估状态（IN_PROGRESS-进行中，COMPLETED-已完成，REVIEWED-已复核）
     */
    @NotBlank(message = "评估状态不能为空")
    @Size(max = 20, message = "评估状态长度不能超过20个字符")
    @Column(name = "evaluation_status", nullable = false, length = 20)
    private String evaluationStatus;

    /**
     * 复核者ID
     */
    @Size(max = 50, message = "复核者ID长度不能超过50个字符")
    @Column(name = "reviewer_id", length = 50)
    private String reviewerId;

    /**
     * 复核时间
     */
    @Column(name = "review_time")
    private LocalDateTime reviewTime;

    /**
     * 复核意见
     */
    @Column(name = "review_comments", columnDefinition = "TEXT")
    private String reviewComments;

    /**
     * 评估版本
     */
    @NotNull(message = "评估版本不能为空")
    @Column(name = "evaluation_version", nullable = false)
    private Integer evaluationVersion;

    /**
     * 上次评估结果对比
     */
    @Column(name = "previous_comparison", columnDefinition = "TEXT")
    private String previousComparison;

    /**
     * 趋势分析（JSON格式）
     */
    @Column(name = "trend_analysis", columnDefinition = "TEXT")
    private String trendAnalysis;

    /**
     * 基准对比（与同类题目对比）
     */
    @Column(name = "benchmark_comparison", columnDefinition = "TEXT")
    private String benchmarkComparison;

    /**
     * 质量标签（JSON格式）
     */
    @Column(name = "quality_tags", columnDefinition = "TEXT")
    private String qualityTags;

    /**
     * 质量指标（JSON格式，详细指标数据）
     */
    @Column(name = "quality_metrics", columnDefinition = "TEXT")
    private String qualityMetrics;

    /**
     * 评估工具信息
     */
    @Column(name = "evaluation_tools", columnDefinition = "TEXT")
    private String evaluationTools;

    /**
     * 数据来源（CALCULATION-计算得出，IMPORTED-导入数据，MANUAL_INPUT-手动输入）
     */
    @Size(max = 30, message = "数据来源长度不能超过30个字符")
    @Column(name = "data_source", length = 30)
    private String dataSource;

    /**
     * 元数据（JSON格式，扩展信息）
     */
    @Column(name = "metadata", columnDefinition = "TEXT")
    private String metadata;

    /**
     * 创建者ID
     */
    @Size(max = 50, message = "创建者ID长度不能超过50个字符")
    @Column(name = "created_by", nullable = false, length = 50)
    private String createdBy;

    /**
     * 创建时间
     */
    @CreatedDate
    @Column(name = "create_time", nullable = false, updatable = false)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @Column(name = "update_time", nullable = false)
    private LocalDateTime updateTime;

    /**
     * 软删除标识
     */
    @NotNull(message = "软删除标识不能为空")
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted;

    /**
     * 删除时间
     */
    @Column(name = "delete_time")
    private LocalDateTime deleteTime;

}